<%@ taglib prefix="extraction" tagdir="/WEB-INF/tags/tissueExtractionTags" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Import Extractions</title>


<!--DHTMLXCOMMON-->
<script type="text/javascript" src="scripts/dhtmlxwindows-codebase/dhtmlxcommon.js" ></script>

<!-- DHTMLXWINDOWS -->
<link rel="STYLESHEET" type="text/css" href="scripts/dhtmlxwindows-codebase/dhtmlxwindows.css">
<link rel="STYLESHEET" type="text/css" href="scripts/dhtmlxwindows-codebase/skins/dhtmlxwindows_dhx_skyblue.css">
<script type="text/javascript" src="scripts/dhtmlxwindows-codebase/dhtmlxcontainer.js" ></script>
<script type="text/javascript" src="scripts/dhtmlxwindows-codebase/dhtmlxwindows.js" ></script>

<!-- DHTMLXVAULT -->
<link rel="STYLESHEET" type="text/css" href="scripts/dhtmlxvault-codebase/dhtmlxvault.css">
<script type="text/javascript" src="scripts/dhtmlxvault-codebase/dhtmlxvault.js" ></script>


<script type="text/javascript" src="scripts/common.js"></script>


<jsp:include page="includes/header.jsp"></jsp:include>
<script type="text/javascript">
	vault=new dhtmlXVaultObject();
		
	function doInitVault(){
		vault.setImagePath("scripts/dhtmlxvault-codebase/imgs/");
		vault.setServerHandlers("includes/dhtmlxvault/UploadHandler.jsp",
	                        "includes/dhtmlxvault/GetInfoHandler.jsp",
	                        "includes/dhtmlxvault/GetIdHandler.jsp");
		vault.setFilesLimit(1);
		
		vault.onAddFile = function(filename){
			var ext = this.getFileExtension(filename);
			if(ext != "xls" && ext != "xlsx"){
				alert("You may only upload excel .xls or xlsx files.");
				return false;
			}
			else{
				return true;
			}
		};
		
		vault.onUploadComplete = function(files){
			  var s=""; 
		      for (var i=0; i<files.length; i++) { 
		         var file = files[i]; 
		         s += ("id:" + file.id + ",name:" + file.name + ",uploaded:" + file.uploaded + ",error:" + file.error)+"\n"; 
		      } 
		      //alert(s);
		      vault.removeAllItems();
		      vault.enableAddButton(true);
		      var fileName = file.name;
		      new Ajax.Request('mainServlet',{
		    	  method: 'POST',
		    	  parameters: {appAction: 'doLoadExtractionImportFile', importFileName: fileName},
		    	  onSuccess: function(transport){
		    		  $('fileContent').update(transport.responseText);
		    	  },
		    	  onFailure : function(transport){
						handleErrorResponseWindow(transport.responseText); //cf. common.js
					} 
			  });
		};
		
		vault.create("vaultDiv");
		vault.setFormField("extractionType", "DNA");
	}
	
	function doInitWin(){
	    dhxWins = new dhtmlXWindows();
	    dhxWins.enableAutoViewport(true);
	    dhxWins.setImagePath("scripts/dhtmlxwindows-codebase/imgs/");
	}
	


</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body onload="doInitWin();doInitVault();">

<div id="container">
<div id="top">
<h1>CHC DB Web</h1>
</div>
<div id="leftnav"><jsp:include page="./includes/leftnav.jsp"></jsp:include></div>
<div id="content">
<h2>Import Extractions</h2>

<input type="hidden" id="appAction" name="appAction" value="listExtractions" />



<fieldset><legend>Upload Import File</legend> 
<div id="vaultDiv"></div>
</fieldset>
<fieldset><legend>Import File Content</legend> 
<div id="fileContent"></div>
</fieldset>

</div>
<div id="footer"><jsp:include page="./includes/footer.jsp"></jsp:include></div>
</div>
</html>